import { assertLogin } from '@/utils/assert.js';
import { createRouter, createWebHistory } from 'vue-router';
import routes from './routes.js';

const router = createRouter({
  history: createWebHistory(),
  routes
});

router.beforeEach((to, from) => {
  if(to.name.startsWith('user')) {
    assertLogin(flag => {
      if(!flag) {
        window.open(from.fullPath, '_self');
      }
    });
  }
})

export default router;